package com.vibrationkeyboard.app.utils

import org.junit.Test
import org.junit.Assert.*

class ConstantsTest {

    @Test
    fun testSampleRateConstants() {
        assertEquals("默认采样频率应该是100Hz", 100, Constants.SAMPLE_RATE_DEFAULT)
        assertTrue("最小采样频率应该小于默认值", Constants.SAMPLE_RATE_MIN < Constants.SAMPLE_RATE_DEFAULT)
        assertTrue("最大采样频率应该大于默认值", Constants.SAMPLE_RATE_MAX > Constants.SAMPLE_RATE_DEFAULT)
    }

    @Test
    fun testSignalProcessingConstants() {
        assertTrue("能量阈值高应该大于低阈值", Constants.ENERGY_THRESHOLD_HIGH > Constants.ENERGY_THRESHOLD_LOW)
        assertTrue("过零率阈值应该在合理范围内", Constants.ZERO_CROSSING_THRESHOLD in 0f..1f)
        assertTrue("最小静音长度应该大于最小语音长度", Constants.MIN_SILENCE_LENGTH > Constants.MIN_SPEECH_LENGTH)
    }

    @Test
    fun testFeatureExtractionConstants() {
        assertTrue("帧长度应该大于帧移", Constants.FRAME_LENGTH > Constants.FRAME_SHIFT)
        assertTrue("FFT大小应该是2的幂", Constants.FFT_SIZE % 2 == 0)
    }

    @Test
    fun testKeyRecognitionConstants() {
        assertTrue("KNN邻居数应该大于0", Constants.KNN_NEIGHBORS > 0)
        assertTrue("置信度阈值应该在0-1之间", Constants.CONFIDENCE_THRESHOLD in 0f..1f)
        assertTrue("最大候选数应该大于0", Constants.MAX_CANDIDATES > 0)
    }

    @Test
    fun testNotificationConstants() {
        assertTrue("通知ID应该大于0", Constants.NOTIFICATION_ID > 0)
        assertNotNull("通道ID不应为null", Constants.CHANNEL_ID)
        assertNotNull("通道名称不应为null", Constants.CHANNEL_NAME)
    }

    @Test
    fun testWearOSConstants() {
        assertTrue("数据路径应该以/开头", Constants.SENSOR_DATA_PATH.startsWith("/"))
        assertTrue("识别结果路径应该以/开头", Constants.RECOGNITION_RESULT_PATH.startsWith("/"))
        assertTrue("命令路径应该以/开头", Constants.COMMAND_PATH.startsWith("/"))
    }

    @Test
    fun testActionConstants() {
        assertNotNull("传感器数据动作不应为null", Constants.ACTION_SENSOR_DATA_ACCELEROMETER)
        assertNotNull("陀螺仪数据动作不应为null", Constants.ACTION_SENSOR_DATA_GYROSCOPE)
        assertNotNull("识别结果动作不应为null", Constants.ACTION_RECOGNITION_RESULT)
    }

    @Test
    fun testSettingsConstants() {
        assertNotNull("设置名称不应为null", Constants.PREFS_NAME)
        assertNotNull("采样频率键不应为null", Constants.KEY_SAMPLE_RATE)
        assertNotNull("传感器延迟键不应为null", Constants.KEY_SENSOR_DELAY)
    }

    @Test
    fun testErrorConstants() {
        assertNotNull("传感器不可用错误消息不应为null", Constants.ERROR_SENSOR_NOT_AVAILABLE)
        assertNotNull("权限被拒绝错误消息不应为null", Constants.ERROR_PERMISSION_DENIED)
        assertNotNull("数据处理错误消息不应为null", Constants.ERROR_DATA_PROCESSING)
    }

    @Test
    fun testSuccessConstants() {
        assertNotNull("传感器启动成功消息不应为null", Constants.SUCCESS_SENSOR_STARTED)
        assertNotNull("传感器停止成功消息不应为null", Constants.SUCCESS_SENSOR_STOPPED)
        assertNotNull("数据保存成功消息不应为null", Constants.SUCCESS_DATA_SAVED)
    }
} 